{% extends 'templates/users/personal.html' %}
<head>
    {% load static %}
    <meta charset="UTF-8">
    <title>活动详情</title>
    {% block headjs %}
    <link rel="stylesheet" href="{% static 'css/layui.css' %}" media="all">
    {% endblock %}
</head>
{% block main %}
    <div class="title">活动详情</div>
    <ul style="width: 95%;margin-left:2.5%;height: 700px;overflow-y: auto">
    <table class="layui-table">
  <colgroup>
    <col>
  </colgroup>
  <thead>
    <tr>
      <th style="width: 5%;">类型</th>
      <th style="width: 10%">图片</th>
      <th style="width: 10%">车名</th>
      <th style="width: 17%">详情</th>
      <th style="width: 12%">价值</th>
      <th style="width: 12%">福利</th>
      <th style="width: 6%">操作</th>
    </tr>
  </thead>
  <tbody>
      {% csrf_token %}
      {% for active in active_list %}
    <tr>
      <td>新车抢先</td>
      <td><img src="/{{ active.img }}"></td>
      <td><p>[{{ active.model }}]</p><p>{{ active.name }}</p></td>
      <td><p>车型:{{ active.rank }}</p><p style="float: left;margin-right: 40px">厂商:{{ active.model }}</p><p>级别:{{ active.rank }}</p><p style="float: left;margin-right: 40px">续航:{{ active.endurance }}</p><p>快充:{{ active.charge }}</p></td>
      <td><p>￥{{ active.price }}</td>
      <td>免首付,长贷5年</td>
      <td>
          <p style="margin-top: 20px"><a href="/flashsale/deleteproduct/{{ active.id }}/">取消</a></p></td>
    </tr>
     {% endfor %}


  </tbody>

</table>
    </ul>


{% endblock %}
{% block footjs %}
            <script src="{% static 'js/jquery.min.js' %}"></script>
        <script src="{% static 'layui/layui.js' %}"></script>
<script>
    //支付
    layui.use(['layer', 'jquery'], function () {
        var $ = layui.jquery;
        var layer = layui.layer;

        $('.pay').on('click', function () {
             // 获取reservationid
            var reservationId = $(this).attr('reservationid');

            $.ajax({
                url: "/reservation/pay/",    // 请求的url地址
                type: "POST",   // 请求方式
                data:{
                    'reservation_id': reservationId, // 确保后端接收的字段名与这里一致
                    'csrfmiddlewaretoken': $('input[name=csrfmiddlewaretoken]').val(),},
                success: function (response) {
                    if (response.url) {
                        window.location.href = response.url;
                    } else {
                        layer.msg('未获取到重定向地址');
                    }
                },
                error: function () {
                    layer.msg('服务器异常');

                }
            });
        });
    });
</script>

{% endblock %}